load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")

package(default_visibility = ["//rs:ic-os-pkg"])

rust_library(
    name = "bare_metal_deployment",
    srcs = [
        "src/deploy.rs",
        "src/lib.rs",
    ],
    compile_data = ["//ic-os/testing:reload_hostos_cmd"],
    rustc_env = {
        "RELOAD_HOSTOS_CMD": "$(execpath //ic-os/testing:reload_hostos_cmd)",
    },
    target_compatible_with = ["@platforms//os:linux"],  # requires Linux-specific dependencies
    visibility = [
        "//rs:ic-os-pkg",
        "//rs:system-tests-pkg",
    ],
    deps = [
        ":build_script",
        "@crate_index//:anyhow",
        "@crate_index//:http",
        "@crate_index//:rand",
        "@crate_index//:rexpect",
        "@crate_index//:slog",
        "@crate_index//:ssh2",
    ],
)

cargo_build_script(
    name = "build_script",
    srcs = ["build.rs"],
)

rust_binary(
    name = "deploy",
    srcs = ["src/main.rs"],
    target_compatible_with = ["@platforms//os:linux"],
    deps = [
        ":bare_metal_deployment",
        "@crate_index//:anyhow",
        "@crate_index//:clap",
        "@crate_index//:slog",
        "@crate_index//:slog-async",
        "@crate_index//:slog-term",
    ],
)
